package _07构造方法;

public class Person {
	// prviate 私有的
	private String name;
	private int age;
	private boolean married;// 是否已婚
	
	public Person(String name, int age, boolean married) {
		super();
		this.name = name;
		this.age = age;
		this.married = married;
	}
	
	public Person() {
		super();

	}



	// Setter方法 setXXX
	public void setName(String name)
	{
		this.name = name;
	}
	
	public void setAge(int age)
	{
		if(age>130 || age<1)
		{
			System.err.println("错误的年龄");
			this.age = 18;
			return;
		}
		this.age = age;
	}
	public void setMarried(boolean married)
	{
		this.married = married;
	}
	
	// Getter 方法 getXXX
	public String getName()
	{
		return this.name;
	}
	
	public int getAge()
	{
		return this.age-2;
	}
	
	// boolean类型的get方法  isXXX
	public boolean isMarried()
	{
		return this.married;
	}

	@Override
	public String toString() {
		return "Person [name=" + name + ", age=" + age + "]";
	}
	
}
